﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UC_UserGroup_List.ascx.cs" Inherits="QuanLyKhachSan.UC_UserGroup_List" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.2.712.35, Culture=neutral, PublicKeyToken=121FAE78165BA3D4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<style type="text/css">
	.ui-dialog { font-size: 11px; }
	body {
		font-family: Tahoma;
		font-size: 12px;
	}
	#question {
		width: 450px!important;
		height: 60px!important;
		padding: 10px 0 0 10px;
	}
	#question img {
		float: left;
	}
	#question span {
		float: left;
		margin: 20px 0 0 10px;
	}
</style>
<script type="text/javascript" language="javascript">
    function frmThemUserGroup_Add() {
        try {
            var URL = '<%=ResolveUrl("~/Pages/PopUp.aspx")%>';
            URL += "?UCName=UC_UserGroup_Edit&UCPath=QuanLyUsers"
            var oRadWindowManager = $find("<%= RadWindowManager1.ClientID %>");
            var frmThemUserGroup = oRadWindowManager.open(URL, "frmThemUserGroup");
            frmThemUserGroup.SetSize(390, 450);
        } catch (e) {
            alert(e);
        }
    }
    function frmThemUserGroup_Edit(UserID) {
        try {
            var URL = '<%=ResolveUrl("~/Pages/PopUp.aspx")%>';
            URL = URL + "?UCName=UC_UserGroup_Edit&UCPath=QuanLyUsers&UserID=" + UserID;
            var oRadWindowManager = $find("<%= RadWindowManager1.ClientID %>");
            var frmThemUserGroup = oRadWindowManager.open(URL, "frmThemUserGroup");
            frmThemUserGroup.SetSize(390, 450);
        } catch (e) {
            alert(e);
        }
    }
    function UserGroup_Delete(UserGroupID, UserName) {
        try {
            var retOK = confirm("Bạn muốn xóa thông tin nhóm tài khoản người dùng: " + UserName);
            if (retOK) {
                var URLService = '<%=ResolveUrl("~/Service/QuanLyUsers/UserGroup.asmx")%>';
                var Method = "UserGroup_Delete";
                $.ajax({
                    type: "POST",
                    url: URLService + "/" + Method,
                    data: "{UserGroupID:" + '"' + UserGroupID + '"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: OnSuccess,
                    error: OnError
                });
            }            
        } catch (e) {
            alert(e);
        }
    }
    function OnSuccess(data, status) {
        __doPostBack('<%=pnlUserGroup.ClientID%>', '');
    }

    function OnError(request, status, error) {
        alert("Có sự cố trong quá trình xử lý.Vui lòng kiểm tra lại!");
    }
    function cmdThemUserGroup_OnClientClicking(sender, args) {
        try {
            args.set_cancel(true);
            frmThemUserGroup_Add();
        } catch (e) {

        }
    }
    
    function OnClientClose(sender, eventArgs) {
        try {
            __doPostBack('<%=pnlUserGroup.ClientID%>', '');
        } catch (e) {

        }
    }
</script>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" 
    EnableShadow="true" Skin="Windows7" Modal="true" VisibleStatusbar="false" >
    <Windows>
            <telerik:RadWindow  
            id="frmThemUserGroup" 
            runat="server"
            showcontentduringload="false"
            width="530px"
            height="400px"
            title="Cập nhật nhóm tài khoản người dùng"
            behaviors="Close,Move,Resize,Maximize"  Animation="Resize" ReloadOnShow="true" OnClientClose="OnClientClose"  >
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<!-- List -->
<table width="100%">
    <tr>
        <td>
            <asp:UpdatePanel ID="pnlUserGroup" runat="server"> 
                <ContentTemplate>
                    <telerik:RadGrid ID="lstUserGroup" runat="server" Skin="Windows7">
                        <MasterTableView DataKeyNames="UserGroupID" AutoGenerateColumns="false" GridLines="None">
                            <CommandItemSettings ExportToPdfText="Export to Pdf" />   
                            <GroupByExpressions>                               
                                <telerik:GridGroupByExpression>
                                    <SelectFields>
                                        <telerik:GridGroupByField FieldName="GroupName" HeaderText="Nhóm người dùng" />
                                    </SelectFields>
                                    <GroupByFields>
                                        <telerik:GridGroupByField FieldName="GroupID" />
                                    </GroupByFields>
                                </telerik:GridGroupByExpression>
                            </GroupByExpressions>
                            <Columns>                   
                                <telerik:GridTemplateColumn HeaderText="Tên tài khoản">
                                    <ItemTemplate>
                                        <%#Eval("UserName")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="150" />
                                    <ItemStyle HorizontalAlign="Left" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Ngày bắt đầu">
                                    <ItemTemplate>
                                        <%#Eval("ExpiryDate")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="200" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Ngày hết hạn">
                                    <ItemTemplate>
                                        <%#Eval("EffectiveDate")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="150" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Dùng thử">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkIsTrialUsed" runat="server" Enabled="false" Checked='<%# (int)Eval("IsTrialUsed") == 1 ? true : false %>' />
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="70" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Chỉnh sửa">
                                    <ItemTemplate>
                                        <span onclick="frmThemUserGroup_Edit(this.title)" title='<%#Eval("UserID") %>' style=" cursor:pointer">Sửa </span>|<span onclick="UserGroup_Delete(this.id,this.title)" title='<%#Eval("UserName") %>' id='<%#Eval("UserGroupID") %>' style=" cursor:pointer"> Xóa</span>                                                                                
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="70" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </telerik:GridTemplateColumn>
                            </Columns>                    
                        </MasterTableView>          
                    </telerik:RadGrid>              
                </ContentTemplate>
            </asp:UpdatePanel>        
        </td>
    </tr>
    <tr>
        <td>            
            <telerik:RadButton ID="cmdThemUserGroup" runat="server" Text="Thêm nhóm tài khoản người dùng" OnClientClicking="cmdThemUserGroup_OnClientClicking">
            </telerik:RadButton>
        </td>
    </tr>
</table>

